<div class="box col-md-12">
	<div class="box-inner">
		<div class="box-header well" data-original-title="">
			<h2>
				<i class="glyphicon glyphicon-user"></i>{$staff}的订单列表
			</h2>

			<div class="box-icon">
				<a href="#" class="btn btn-minimize btn-round btn-default"> <i
					class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
					class="btn btn-close btn-round btn-default"> <i
					class="glyphicon glyphicon-remove"></i></a>
			</div>
		</div>
		<div class="box-content">
			<div class="alert alert-info">
				对订单进行查看、管理以及
				<button id="choose" style="margin-right: 50px;" type="button"
					class="btn  btn-success">配送</button>
			</div>

			<table
				class="table table-striped table-bordered bootstrap-datatable datatable responsive"
				id="orderlist">
				<thead>
					<tr>
						<th><input type="checkbox" id="all" />订单号</th>
						<th>订单商家</th>
						<th>订单总价</th>
						<th>订单配送区域</th>
						<th>下单日期</th>
						<th>下单时间</th>
						<th>支付方式</th>
						<th>状态</th>
						<th>订单配送时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="tbody">
					<foreach name="list" item="v">
					<tr>
						<td><if condition="$v['status'] eq 0"> <input type="checkbox"
								value="{$v.id}" name="check[]" /></if><a
							href="javascript:void(0);">{$v.id}</a></td>
						<td>{$v.account}</td>
						<td>{$v.food_price}元</td>
						<td>{$v.area}</td>
						<td>{$v.cdate}</td>
						<td>{$v.ctime}</td>
						<td><if condition="$v.payment eq 1">在线支付<else />货到付款</if></td>
						<td><switch name="v.status"> <case value="0">未配送</case> <case
								value="1">配送中</case> <case value="2">已配送</case> <case value="3">已收款</case>
							</switch></td>
						<td>{$v.ptime}</td>
						<td><label style="height: 26px;"><a
								href="javascript:details('{$v.id}');">查看详情 ></a></label></td>
					</tr>
					</foreach>
				</tbody>
				<tfoot>
					<tr>
						<th style="visibility: hidden;">订单号</th>
						<th>订单商家</th>
						<th style="visibility: hidden;">订单总价</th>
						<th>订单配送区域</th>
						<th>下单日期</th>
						<th style="visibility: hidden;">下单时间</th>
						<th>支付方式</th>
						<th>状态</th>
						<th>订单配送时间</th>
						<th style="visibility: hidden;">操作</th>
					</tr>
				</tfoot>
			</table>
		</div>
		<!-- end box-content -->
	</div>
	<!-- end box-inner -->
</div>
<!-- end row -->
<!-- 选择配送员弹出框 -->
<div class="modal fade" id="ChooseModal" tabindex="-1" role="dialog"
	aria-labelledby="markiModal" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">配送</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal style-form" id="form1"
					action="__APP__/Admin/Order/choose" method="post">
					<div class="form-group">
						<label class="col-sm-3 control-label">配送时间：</label>
						<div class="col-sm-9 ">
							<select name="ptime" class="form-control">
								<foreach name="ptimes" item="ptime">
								<option value="{$ptime}">{$ptime}</option>
								</foreach>
							</select>
						</div>
						<div id="orders" style="display: none;"></div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-danger">确认</button>
			</div>
		</div>
	</div>
</div>
<!-- end row -->
<!-- 订单详情弹出框 -->
<div class="modal fade" id="orderDetailsModal" tabindex="-1"
	role="dialog" aria-labelledby="markiModal" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content" id="detail_content"></div>
	</div>
</div>
<script src="__PUBLIC__/js/staff_box.js"></script>
<script type="text/javascript">
  var geturl = "__APP__/Admin/Order/getData";
  var detailsUrl = "__APP__/Admin/Order/details";
  $(function(){
//	  var date = "<?php echo date('Y-m-d'); ?>";
//       $('#startTime').val(date);
//       $('#startTime').datetimepicker({lang:'ch'});
//       $('#startTime').datetimepicker({
//         timepicker:false,
//         format:'Y-m-d'
//       });
  });
  function details(id){
		$.post(detailsUrl,{id:id},function(data){
			$("#detail_content").html(data);
		});
		$("#orderDetailsModal").modal('show');
 }
  $("#all").click(function(){
	var isChecked = this.checked;
	$("input[type='checkbox']").each(function(){
		this.checked = isChecked;
	}); 
  });
  $("#choose").click(function(){
// 	  $("input[name='sh']").attr("checked",this.checked);
	  var checkboxes = $("input[name='check[]']");
	  var count = checkboxes.length;
	  var str = "";
	  var num = 0;
	  $('#orders').html("");
	  for(i=0;i<count;i++){
		  var checkbox = checkboxes[i];
		  if(checkbox.checked){
			  var input = "<input type='text' name='orderId[]' value='"+checkbox.value+"'/>";
			  $('#orders').append(input);
			  str += checkbox.value+",";
			  num++;
		  }
	  }
//	  console.log('num:'+num);
	  if(num ==0){
		  alert("请先选择一个订单");
	  }else{
		  $("#ChooseModal").modal('show');
	  }
// 	  console.log("checkbox:"+str);
// 	  console.log("checkboxNum:"+num);
	});
  $('#ChooseModal').on('click','button.btn-danger',function (a){
	  $("#form1").submit();
	});
  </script>
